//
//  ShopGoodsTableViewCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/9.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "ShopGoodsTableViewCell.h"

@interface ShopGoodsTableViewCell ()

@property (nonatomic, strong) UIImageView *headImage;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UILabel *statuLabel;

@end

@implementation ShopGoodsTableViewCell

- (void)setShopGoodsListModel:(ShopGoodsListModel *)shopGoodsListModel {
    _shopGoodsListModel = shopGoodsListModel;
    
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:shopGoodsListModel.url] placeholderImage:nil options:SDWebImageRetryFailed];
    self.nameLabel.text = shopGoodsListModel.design_name;
    self.detailLabel.text = [NSString stringWithFormat:@"售价：%@元",shopGoodsListModel.price];
    if ([shopGoodsListModel.statu integerValue] == 0) {
        self.statuLabel.textColor = REXADECIMALCOLOR(@"#999999");
        self.statuLabel.text = [NSString stringWithFormat:@"成交笔数：%@",shopGoodsListModel.volume];
    }else if ([shopGoodsListModel.statu integerValue] == 1) {
        self.statuLabel.textColor = REXADECIMALCOLOR(@"#999999");
        self.statuLabel.text = shopGoodsListModel.design_des;
    }else if ([shopGoodsListModel.statu integerValue] == 2) {
        self.statuLabel.textColor = ThemeColor;
        self.statuLabel.text = shopGoodsListModel.design_des;
    }else if ([shopGoodsListModel.statu integerValue] == 3) {
        self.statuLabel.textColor = ThemeColor;
        self.statuLabel.text = shopGoodsListModel.design_des;
    }
}

+ (ShopGoodsTableViewCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"ShopGoodsTableViewCell";
    ShopGoodsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[ShopGoodsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    self.headImage = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(15), ScreenX375(103), ScreenX375(71))];
    self.headImage.layer.cornerRadius = ScreenX375(5);
    self.headImage.clipsToBounds = YES;
    self.headImage.image = [UIImage imageNamed:@"头部背景"];
    [self addSubview:self.headImage];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(126), ScreenX375(14), ScreenX375(200), ScreenX375(16))];
    self.nameLabel.text = @"纸箱纸板";
    self.nameLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.nameLabel.font = Kfont(14);
    [self addSubview:self.nameLabel];
    
    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(126), ScreenX375(35), ScreenX375(200), ScreenX375(17))];
    self.detailLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.detailLabel.font = Kfont(12);
    self.detailLabel.text = @"售价：699元";
    [self addSubview:self.detailLabel];
    
    self.statuLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(126), ScreenX375(55), ScreenX375(200), ScreenX375(15))];
    self.statuLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.statuLabel.font = Kfont(12);
    self.statuLabel.text = @"成交笔数：699";
    [self addSubview:self.statuLabel];
    
    UIImageView *sLine = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(101) - 0.5, SCREEN_WIDTH - ScreenX375(26), 0.5)];
    sLine.image = [UIImage imageNamed:@"虚线"];
    [self addSubview:sLine];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@implementation ShopGoodsListModel

+(JSONKeyMapper*)keyMapper
{
    return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{
                                                                  @"Id": @"id",
                                                                  }];
}

@end
